/*
 * @Author: wuqingchun
 * @Date: 2024-05-07 18:59:59
 * @Description: task queue header file
 * @LastEditors: wuqingchun
 * @LastEditTime: 2024-05-07 19:30:47
 */
#ifndef __TASK_QUEUE_H__
#define __TASK_QUEUE_H__

#include <type_traits>
#include <cstdint>
#include <atomic>

template <typename T>
class TaskQueue
{
    static_assert(std::is_pointer<T>, "T must be a pointer type");
    
    struct Array
    {
        int64_t i64Capacity;
        int64_t i64Mask;
        std::atomic<T>* pAtmArray;

        explicit Array(int64_t i64Capacity):
            i64Capacity(i64Capacity),
            i64Mask(i64Capacity - 1),
            pAtmArray(new std::atomic<T>[static_cast<size_t>(i64Capacity)])
        {
            
        }

        ~Array()
        {
            delete [] pAtmArray;
        }

        int64_t capacity() const noexcept 
        {
            return i64Capacity;
        }
    };
};

#endif //__TASK_QUEUE_H__